#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
KubeRelayer 请求拦截/重放/监听组件入口
"""

import os
import logging
from intercept.api.app import create_app

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

logger = logging.getLogger(__name__)

def main():
    """主函数"""
    logger.info("启动 KubeRelayer 请求拦截/重放/监听组件...")

    # 创建应用
    app = create_app()

    # 获取环境变量
    host = os.environ.get('HOST', '0.0.0.0')
    port = int(os.environ.get('PORT', 5555))
    debug = os.environ.get('DEBUG', 'False').lower() == 'true'

    logger.info(f"服务将在 {host}:{port} 上运行")

    # 启动应用
    app.run(host=host, port=port, debug=debug)

if __name__ == '__main__':
    main()
